//
//  MeetingTableViewCellStyle2.m
//  HuaRun2
//
//  Created by admin on 17/9/4.
//  Copyright © 2017年 Sunny. All rights reserved.
//

#import "MeetingTableViewCellStyle2.h"
#import "LineView.h"
#import "ImageValueLabelStyle2.h"
#import "ImageLabView.h"
#import "Com_MeetingModel.h"

@interface MeetingTableViewCellStyle2 ()
@property(nonatomic, strong) UILabel * nameLab;
//时间、时区
@property (nonatomic, strong) ImageValueLabelStyle2 * timeLable;
//地区
@property (nonatomic, strong) ImageLabView * locationLabel;

//分割线
@property (nonatomic, strong) LineView * lineView;
@end

@implementation MeetingTableViewCellStyle2

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
#pragma mark - life cycle
- (void)dealloc {
NSLog(@"%@ dealloc", [self class]);
}

- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.contentView.backgroundColor = RGBA(249, 249, 249, 1);
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        [self viewInit];
        [self layoutInit];
    }
    return self;
}

- (void)viewInit {
    
    [super viewInit];
//    self.backView.backgroundColor = kRandomColor;
    [self.contentView addSubview:self.nameLab];
    
    [self.contentView addSubview:self.timeLable];
    [self.contentView addSubview:self.locationLabel];
    
    [self.contentView addSubview:self.lineView];
}

- (void)layoutInit {

//    [super layoutInit];
    
    weakself(ws);
    [self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(ws.contentView).offset(kMargin10);
        make.right.mas_equalTo(ws.contentView).offset(-kMargin10);
        make.top.mas_equalTo(ws.contentView).offset(kMargin10);
        make.bottom.mas_equalTo(ws.contentView);
    }];

    [self.nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(ws.timeLable);
        make.top.mas_equalTo(ws.backView).offset(kMargin10);
    }];

    [self.timeLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(ws.backView).offset(kMargin10);
        make.right.mas_equalTo(ws.backView).offset(-kMargin10);
        make.top.mas_equalTo(ws.nameLab.mas_bottom).offset(kMargin10);
    }];
    
    [self.locationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(ws.timeLable);
        make.top.mas_equalTo(ws.timeLable.mas_bottom).offset(0);
        make.bottom.mas_equalTo(ws.backView).offset(-2);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(ws.backView);
        make.left.mas_equalTo(ws.backView).offset(0);
        make.right.mas_equalTo(ws.backView).offset(0);
        make.height.mas_equalTo(1);
    }];
}


#pragma mark - getter setter
- (void)setCom_MeetingModel:(Com_MeetingModel *)com_MeetingModel {
    _com_MeetingModel = com_MeetingModel;
    
    _nameLab.text = [NSString showStringWithStr:com_MeetingModel.name];
    _timeLable.valueLab1.text =
    [NSString showStringWithStr:com_MeetingModel.timezone];

    _timeLable.valueLab2.text =
    [NSString stringWithFormat:@"%@-%@",
                     [NSString showStringWithStr:com_MeetingModel.startTime],
                     [NSString showStringWithStr:com_MeetingModel.endTime]
                     ];    
    _locationLabel.nameLab.text = [NSString showSpaceStringWithStr:com_MeetingModel.location];
    
}
- (UILabel *)nameLab {
    if (!_nameLab) {
        self.nameLab = [UILabel new];
        _nameLab.textAlignment = NSTextAlignmentLeft;
        _nameLab.font = kGeneralFontSize;
        _nameLab.textColor = [UIColor colorWithHex:@"3c3c3c"];
    }
    return _nameLab;
}

- (ImageValueLabelStyle2 *)timeLable {
    if (!_timeLable) {
        self.timeLable = [ImageValueLabelStyle2 new];
//        _timeLable.valueLab1.text = @"1";
//        _timeLable.valueLab2.text = @"33eee";
        _timeLable.keyImageView.image = [UIImage imageNamed:@"时间_1"];
    }
    return _timeLable;
}

- (ImageLabView *)locationLabel {
    if (!_locationLabel) {
        self.locationLabel = [ImageLabView new];
//        _locationLabel.backgroundColor = kRandomColor;
//        _locationLabel.nameLab.text = kTestStr;
        _locationLabel.iconView.image = [UIImage imageNamed:@"地址_1"];
        _locationLabel.userInteractionEnabled = NO;
    }
    return _locationLabel;
}

- (LineView *)lineView {
    if (!_lineView) {
        self.lineView =  [LineView new];
        
    }
    return _lineView;
}

@end
